package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.app.UserLoginService;
import com.ruoyi.system.vo.MiniProgramLoginVO;
import com.ruoyi.system.vo.WxSessionResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/login")
@Slf4j
public class UserLoginController extends BaseController {

    @Resource
    private UserLoginService userLoginService;


    @GetMapping("/miniProgramLogin")
    public AjaxResult miniProgramLogin(@RequestParam String code) {
        MiniProgramLoginVO miniProgram = userLoginService.miniProgramLogin(code);
        return AjaxResult.success(miniProgram);
    }

    @GetMapping("/jscode2session")
    public AjaxResult jscode2session(@RequestParam String code) {
        WxSessionResp wxSessionResp = userLoginService.jscode2session(code);
        return AjaxResult.success(wxSessionResp);
    }


}
